import java.util.Arrays;

public class Text {
    public static void main(String[] args) {
        int[] arr = {1,2,0,0,4,0,12};
        for(int cur=0, dest=-1;cur< arr.length;cur++){
            if(arr[cur]!=0){
                dest++;
                int tmp = arr[cur];
                arr[cur] = arr[dest];
                arr[dest] = tmp;
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
